﻿using NewsMine.Storage;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;

namespace NewsMine.Storage.Tests
{


    /// <summary>
    ///This is a test class for KeyValueStoreManagerOnFileSystemTest and is intended
    ///to contain all KeyValueStoreManagerOnFileSystemTest Unit Tests
    ///</summary>
    [TestClass()]
    public class KeyValueStoreManagerOnFileSystemTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for KeyValueStoreManagerOnFileSystem Constructor
        ///</summary>
        [TestMethod()]
        public void KeyValueStoreManagerOnFileSystemConstructorTest()
        {
            KeyValueStoreManagerOnFileSystem target = new KeyValueStoreManagerOnFileSystem();
        }

        /// <summary>
        ///A test for CreateKeyValueStore
        ///</summary>
        [TestMethod()]
        public void CreateKeyValueStoreTest()
        {
            KeyValueStoreManagerOnFileSystem target = new KeyValueStoreManagerOnFileSystem(); // TODO: Initialize to an appropriate value
            string name = "testStore";
            target.CreateKeyValueStore(name);

            var kvStore = target.GetKeyValueStoreByName(name);

            var kvStores = target.GetListOfKeyValueStore();

            Assert.IsNotNull(kvStore);

            Assert.IsNotNull(kvStores);
            Assert.IsTrue(kvStores.Length > 0);

            target.DeleteKeyValueStore(name);

            kvStores = target.GetListOfKeyValueStore();

            Assert.IsTrue(kvStores.Length == 0);


        }
        /// <summary>
        ///A test for GetItemCount
        ///</summary>
        [TestMethod()]
        public void GetItemCountTest()
        {
            KeyValueStoreManagerOnFileSystem target = new KeyValueStoreManagerOnFileSystem(); // TODO: Initialize to an appropriate value
            string name = "testStore";
            target.CreateKeyValueStore(name);

            var kvStore = target.GetKeyValueStoreByName(name);

            var kvStores = target.GetListOfKeyValueStore();

            Assert.IsNotNull(kvStores);
            Assert.IsTrue(kvStores.Length > 0);

            //string key = "http://testDoamin.com/testpage.aspx";
            string key = "1231312321";
            string value = "<html> <head></head> </html";

            kvStore.Set(key, value);

            string returnedValue = (string) kvStore.Get(key);

            Assert.AreEqual(value, returnedValue);

            target.DeleteKeyValueStore(name);

            kvStores = target.GetListOfKeyValueStore();

            Assert.IsTrue(kvStores.Length == 0);

        }

        /// <summary>
        ///A test for GetKeyValueFolderByName
        ///</summary>
        [TestMethod()]
        [DeploymentItem("NewsMine.Storage.dll")]
        public void GetKeyValueFolderByNameTest()
        {
            KeyValueStoreManagerOnFileSystem_Accessor target = new KeyValueStoreManagerOnFileSystem_Accessor(); // TODO: Initialize to an appropriate value
            string name = string.Empty; // TODO: Initialize to an appropriate value
            string expected = string.Empty; // TODO: Initialize to an appropriate value
            string actual;
            actual = target.GetKeyValueFolderByName(name);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }

        /// <summary>
        ///A test for GetKeyValueStoreByName
        ///</summary>
        [TestMethod()]
        public void GetKeyValueStoreByNameTest()
        {
            KeyValueStoreManagerOnFileSystem target = new KeyValueStoreManagerOnFileSystem(); // TODO: Initialize to an appropriate value
            string name = string.Empty; // TODO: Initialize to an appropriate value
            IKeyValueStore expected = null; // TODO: Initialize to an appropriate value
            IKeyValueStore actual;
            actual = target.GetKeyValueStoreByName(name);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }

        /// <summary>
        ///A test for GetListOfKeyValueStore
        ///</summary>
        [TestMethod()]
        public void GetListOfKeyValueStoreTest()
        {
            KeyValueStoreManagerOnFileSystem target = new KeyValueStoreManagerOnFileSystem(); // TODO: Initialize to an appropriate value
            string[] expected = null; // TODO: Initialize to an appropriate value
            string[] actual;
            actual = target.GetListOfKeyValueStore();
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }

        /// <summary>
        ///A test for ValidateKeyValueStoreName
        ///</summary>
        [TestMethod()]
        [DeploymentItem("NewsMine.Storage.dll")]
        public void ValidateKeyValueStoreNameTest()
        {
            KeyValueStoreManagerOnFileSystem_Accessor target = new KeyValueStoreManagerOnFileSystem_Accessor(); // TODO: Initialize to an appropriate value
            string name = string.Empty; // TODO: Initialize to an appropriate value
            target.ValidateKeyValueStoreName(name);
            Assert.Inconclusive("A method that does not return a value cannot be verified.");
        }
    }
}
